package com.Test.HomeWork;

import java.io.*;
import java.util.ArrayList;

class Person{
    private String userName; //张三
    private String idcard; // 430302198812213051
    private String account; //9558803602160971001
    private Double money;

    public Person(String userName, String idcard, String account, Double money) {
        this.userName = userName;
        this.idcard = idcard;
        this.account = account;
        this.money = money;
    }




    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getIdcard() {
        return idcard;
    }

    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public Double getMoney() {
        return money;
    }

    public void setMoney(Double money) {
        this.money = money;
    }

    @Override
    public String toString() {
        return "\nPerson{" +
                "userName='" + userName + '\'' +
                ", idcard='" + idcard + '\'' +
                ", account='" + account + '\'' +
                ", money=" + money +
                '}';
    }
}
public class work8 {
    public static void main(String[] args) throws IOException {
        File file=new File("G:\\培训班\\代码块\\week4\\day2\\src\\a1.txt");

        System.out.println(ReadFile(file).toString());
        //ReadFile2(file);
    }

    public static ArrayList<Person> ReadFile(File file) throws IOException {
        FileReader fileReader=new FileReader(file);
        BufferedReader bufferedReader=new BufferedReader(fileReader);

        ArrayList<Person> people = new ArrayList<>();
        String line=null;
        while ((line=bufferedReader.readLine())!=null){
            String[] arr=line.split("\\|");
            String name=arr[0].trim();
            String idcard=arr[1].trim();
            String account=arr[2].trim();
            Double money= Double.valueOf(arr[3].trim());
            Person p=new Person(name,idcard,account,money);
            people.add(p);

        }
        fileReader.close();
        //System.out.println(people.toString());
        return people;
    }
}
